package jwdt.xadmin.goods.action;

import jwdt.common.action.BaseAction;
import jwdt.xadmin.goods.bean.TGoodsClass;
import jwdt.xadmin.goods.service.GoodsClassManageService;

import com.ezerg.db.ext.PageUtil;
import com.ezerg.web.Form;
import com.ezerg.web.Module;
import com.ezerg.web.Page;
import com.ezerg.web.annotation.Controller;
import com.ezerg.web.annotation.RequestMapping;

@Controller("/xadmin/goods")
public class GoodsClassManageAction extends BaseAction {
	
	GoodsClassManageService goodsClassManageService = app.getBean("GoodsClassManageService");
	
	@RequestMapping("/typeLeftTree")
	public Page doNewsLeft(Form f, Module m)throws Exception {
		return m.getJsonPage(f, goodsClassManageService.typeLeftTree());
	}
	
	@RequestMapping("/selectGoodsClassList")
	public Page doSelectGoodsClassList(Form f,Module m)throws Exception{
		int fid = f.getInt("fid", 0);
		PageUtil pu = (PageUtil) f.copy2Class(PageUtil.class);
		return m.getWritePage(f, goodsClassManageService.selectGoodsClassList(pu,fid).toJson());
	}
	
	@RequestMapping("/goodsClass")
	public Page doAllGoodsClass(Form f,Module m)throws Exception{
		int fid = f.getInt("fid", 0);
		return m.getJsonPage(f, goodsClassManageService.allGoodsClass(fid));
	}
	
	@RequestMapping("/goodsnoteClass")
	public Page doAllnoteGoodsClass(Form f,Module m)throws Exception{
		int fid = f.getInt("fid", 0);
		return m.getJsonPage(f, goodsClassManageService.allnoteGoodsClass(fid));
	}
	
	@RequestMapping("/selectOneGoodsClass")
	public Page doSelectOneGoodsClass(Form f,Module m)throws Exception{
		int classid = f.getInt("classid");
		return m.getJsonPage(f, goodsClassManageService.selectOneGoodsClass(classid));
	}
	
	@RequestMapping("/saveGoodsClass")
	public Page doSaveGoodsClass(Form f,Module m)throws Exception{
		int classid = f.getInt("classid");
		TGoodsClass obj = (TGoodsClass) f.copy2Class(TGoodsClass.class);
		return m.getJsonPage(f, goodsClassManageService.saveGoodsClass(classid, obj));
	}
	
	@RequestMapping("/delGoodsClass")
	public Page doDelGoodsClass(Form f,Module m)throws Exception{
		int classid = f.getInt("classid");
		return m.getJsonPage(f, goodsClassManageService.delGoodsClass(classid));
	}

}
